www.gusucode.com > 落叶冰点万能企业网站内容管理系统 V9.1 > 落叶冰点万能企业网站内容管理系统 V9.1\code\admin\D_u_photo_up.asp
<% '************************************************************** ' 新动软网站管理系统 ' 官方网站: http://www.aspcpu.com ' 系统作者: 阮丁远(网名:天下程序) ' Copyright 新动软网站管理系统 版权所有 '************************************************************** %> <% '----------------------------------------相册系统: dir_set="../" %> <%Server.ScriptTimeOut=5000%> <!--#include file="../inc/conn.asp"--> <!--#include file=inc/sys.asp--> <!--#include file=inc/get.asp--> <!--#include file=../inc/ND_class_function.asp--> <!--#include file=../inc/functionFiless.asp--> <!--#include FILE="upload_5xsoft.asp"--> <!--#include file=../inc/jpeg_draw.asp--> <% dim ifphoto UserName=Request.Cookies("nd_cache_varb_blog")("UserName") Password=Request.Cookies("nd_cache_varb_blog")("Password") userlevel=Request.Cookies("nd_cache_varb_blog")("userlevel") if UserName="" then response.Redirect "../blog/userlogin.asp" else set rsuu=Server.CreateObject("ADODB.recordset") rsuu.open"select * from ND_user where [username]='"&UserName&"'",conn,1,1 set rsuu2=Server.CreateObject("ADODB.recordset") rsuu2.open"select * from ND_userGroup where id="&rsuu("lever_id")&"",conn,1,1 grade=clng(rsuu2("grades")) userid=rsuu("id") %> <% Function RelativePath2RootPath(url) Dim sTempUrl sTempUrl = url If Left(sTempUrl, 1) = "/" Then RelativePath2RootPath = sTempUrl Exit Function End If Dim m_strPath m_strPath = Request.ServerVariables("SCRIPT_NAME") m_strPath = Left(m_strPath, InStrRev(m_strPath, "/") - 1) Do While Left(sTempUrl, 3) = "../" sTempUrl = Mid(sTempUrl, 4) m_strPath = Left(m_strPath, InStrRev(m_strPath, "/") - 1) Loop RelativePath2RootPath = m_strPath & "/" & sTempUrl End Function If Trim(request("Action"))="Upload" then dddllld=1 if grade<=2 then set rs=Server.CreateObject("ADODB.recordset") rs.open"select count(id) from ND_userphotos where userid='"&userid&"'",conn,1,1 ifphoto=rs(0) rs.close:set rs=nothing if ifphoto>D_u_1_max_photos then dddllld=0 Call msg("Sorry!\n\n普通会员最多只能上传"&D_u_1_max_photos&"张照片\n\n请到照片管理中心删除部分照片","-1") end if elseif grade=3 then set rs=Server.CreateObject("ADODB.recordset") rs.open"select count(id) from ND_userphotos where userid='"&userid&"'",conn,1,1 ifphoto=rs(0) rs.close:set rs=nothing if ifphoto>D_u_2_max_photos then dddllld=0 Call msg("Sorry!\n\n诚信会员、会长最多只能上传"&D_u_2_max_photos&"张照片\n\n请到照片管理中心删除部分照片","-1") end if elseif grade=4 then set rs=Server.CreateObject("ADODB.recordset") rs.open"select count(id) from ND_userphotos where userid='"&userid&"'",conn,1,1 ifphoto=rs(0) rs.close:set rs=nothing if ifphoto>D_u_3_max_photos then dddllld=0 Call msg("Sorry!\n\n诚信会员、会长最多只能上传"&D_u_3_max_photos&"张照片\n\n请到照片管理中心删除部分照片","-1") end if end if if dddllld=1 then Call UploadData() end if End If Sub msg(ssddd) %> <script language="javascript"> alert("<%=ssddd%>"); history.go(-1); </script> <% response.end end sub Sub UploadData() dim upload,file,formName,formPath,iCount set upload=new upload_5xsoft ''建立上传对象 formPath=upload.form("filepath") S_Width=100 S_Height=100 Title=Replace(Replace(Replace(upload.form("title"),"'",""),"<","<"),">",">") if Trim(Title)="" then %> <script language="javascript"> alert("照片说明 不能为空"); history.go(-1); </script> <% else unlod=0 if unlod=0 then ''在目录后加(/) if right(formPath,1)<>"/" then formPath=formPath&"/" iCount=0 randomize ranNum=int(999*rnd) filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum sUploadDir="../uploadfile/userphotos/" call createfile(sUploadDir&"11.txt","1111",true) call deletefile(sUploadDir&"11.txt") strUploadDir = CreatePath(sUploadDir) sUploadDir = sUploadDir & strUploadDir formPath=sUploadDir err1=0 for each formName in upload.objFile ''列出所有上传了的文件 set file=upload.file(formName) ''生成一个文件对象 if file.FileSize>D_u_AllowFilesize then response.write "文件太大,上传失败! <a href=D_upfile.asp>重新上传</a><script>alert('文件太大,上传失败!');</script>" err1=1 end if eee1=File.FileName extnm=mid(eee1,inStrRev(eee1,".")+1,len(eee1)-inStrRev(eee1,".")) okkk=0 ssss111=split(D_u_AllowFileExt,"|") for iyy=0 to ubound(ssss111) ssss1112=ssss111(iyy) if lcase(trim(cstr(ssss1112)))=lcase(trim(cstr(extnm))) then okkk=1 exit for end if next FileType=lcase(trim(cstr(extnm))) If instr(1,FileType,"jpeg",1)<=0 and instr(1,FileType,"gif",1)<=0 and instr(1,FileType,"jpg",1)<=0 and instr(1,FileType,"png",1)<=0 Then okkk=0 end if if okkk=0 then err1=1 response.write "文件类型不正确,上传失败,必须是.jpg, .jpeg ,.gif ,.png的图片! <a href=D_upfile.asp>重新上传</a><script>alert('文件类型不正确,上传失败,必须是.jpg, .jpeg ,.gif ,.png的图片!');</script>" end if if file.FileSize>0 and err1=0 then ''如果 FileSize > 0 说明有文件数据 file.SaveAs Server.mappath(formPath&filename&"."&extnm) ''保存文件 call do_shuiying(formPath&filename&"."&extnm) ' response.write file.FilePath&filename&" ("&file.FileSize&") => "&formPath&File.FileName&" 上传成功!<br>" ttttppppt=RelativePath2RootPath(formPath&filename&"."&extnm) response.write File.FileName&" 上传成功! " '信息入库 set rs= Server.CreateObject("ADODB.Recordset") rs.open"select * from ND_userphotos",conn,1,3 set rsdd= Server.CreateObject("ADODB.Recordset") rsdd.open"select * from ND_userphotos where userid='"&userid&"' and ifmain=1",conn,1,1 Rs.addnew rs("userid")=userid rs("picurl_s")=ttttppppt rs("title")=title rs("is_shenhe")=1 if rsdd.eof then rs("ifmain")=1 else rs("ifmain")=0 end if rs("addtime")=now() rs.update response.redirect "D_u_photo_list.asp" end if set file=nothing next set upload=nothing ''删除此对象 end if end if End Sub %><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>上传照片</title> <script language="javascript"> var img=null; function showtype() { if(document.up.title.value=="") {alert("请输入照片说明!"); document.up.title.focus(); return false; } var fsize=0; if(img)img.removeNode(true); img=document.createElement("img"); img.style.position="absolute"; img.style.visibility="hidden"; document.body.insertAdjacentElement("beforeend",img); img.src=up.inp.value; var ftype=img.src.substring(img.src.length-4,img.src.length) ftype=ftype.toUpperCase(); fsize=img.fileSize; if((ftype.indexOf('JPG',0)==-1) && (ftype.indexOf('GIF', 0)==-1)&& (ftype.indexOf('JPEG', 0)==-1)&& (ftype.indexOf('PNG', 0)==-1)) { alert("Sorry!上传失败!\n\n①请选择您要上传的照片\n\n②且只能是.JPG或.GIF,.jpeg .png图片类型。"); return false; } return true; } </script> </head> <LINK href="css.css" type=text/css rel=stylesheet> <table width="778" height="7" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FF156D"> <tr> <td></td> </tr> </table> <table width="778" height="491" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="FFD7ED"> <tr> <td width="160" align="center" valign="top" bgcolor="#FFFFFF"> <br> </td> <td width="618" align="center" valign="top" bgcolor="#FFFFFF"><table width="100%" height="6" border="0" cellpadding="0" cellspacing="0" bgcolor="ECF9FF"> <tr> <td></td> </tr> </table> <table width="100%" height="52" border="0" cellpadding="0" cellspacing="0" background="images/titlebg2.gif"> <tr> <td width="42%"><img src="images/usertitle10.gif" width="231" height="52" ></td> <td width="58%" valign="top"><table width="75" height="9" border="0" cellpadding="0" cellspacing="0"> <tr> <td></td> </tr> </table> <a href="D_u_photo_list.asp"><img src="images/photpmanage.gif" width="99" height="21" hspace="5" border="0"></a> <a href="D_u_photo_up.asp"><img src="images/photpmanage2.gif" width="99" height="21" hspace="5" border="0"></a></td> </tr> </table> <br> <table width="569" border="0" cellpadding="0" cellspacing="0" > <tr> <td align="center">你知道吗?有照片的 浏览量至少会提高<b>10</b>倍以上。</font></td> </tr> </table> <br> <table width="583" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"> <form method="POST" enctype="multipart/form-data" action="D_u_photo_up.asp?Action=Upload" name="up" onSubmit="return showtype()"> <tr> <td width="100%" height="40" align="left" colspan=2><font color="#FF3300">注意:上传的第一张将默认设为你的头像!</font></td> </td> </tr> <tr> <td width="150" height="40" align="right">照片简单说明:</td> <td width="433" style="line-height:200%;font-size:10.3pt;color:33333;"><input name="title" type="text" id="title" size="40" maxlength="50" > </td> </tr> <tr> <td width="150" height="40" align="right">请选择本地照片:</td> <td width="433" style="line-height:200%;font-size:10.3pt;color:33333;"><input name="Pic" type="file" id="inp" style="font-size:9pt;" size="40"> </td> </tr> <tr> <td width="150" height="60"> </td> <td width="433""> <input type="image" src="images/upload.gif"> </td> </tr> </form> </table> <table width="569" border="0" cellpadding="0" cellspacing="0" > <tr> <td width="16"> </td> <td width="514" valign="top" style="line-height:170%;"><b><br> </b><font color="#666666"> <font color="#3298C9"> 1、</font><font color="#666666"><font color="#3298C9">你的照片必须是<font color="#FF0000">.jpg</font>或<font color="#FF0000">.gif</font>格式。 </font></font><font color="#3298C9"><br> 2、严禁上传色情图片,一经发现,我们将删除您的帐号。<br> 3、请保证您上传的照片与您目前的面貌相差不远,不要上传合影、画像、合成照片、小时候的照片等不适于做个人形象照的</font><font color="#666666"><font color="#3298C9">照片</font></font><font color="#3298C9">。<br> 4、请确保您上传的</font><font color="#666666"><font color="#3298C9">照片</font></font><font color="#3298C9">不得违反国家有关规定。<br> 5、</font><font color="#666666"><font color="#666666"><font color="#3298C9">不要上传明星照、卡通图片、风景照以及其他的虚假图片;</font></font></font><font color="#3298C9"><br> 6、</font><font color="#666666"></font><font color="#666666"><font color="#3298C9">本站将对您的照片保留最终决定权。</font></font><font color="#3298C9"><br> 如果您通过印刷品、网页或其他途径盗用他人图片,所产生的一切后果由您自己承担,一经发现,我们将删除您的帐号。</font></font></td> </tr> </table> </td> </tr> </table> <table width="778" height="5" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" > <tr> <td></td> </tr> </table> </body> </html> <% end if %>